
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// 全部的路由规则
const routes = [
  // 登录页面的路由规则  这里的name指的是组件路由的名字  自定义的
  // { path: '/', redirect: '/login' },
  { path: '/login', name: 'login', component: () => import('@/views/login/index.vue') },
  {
    path: '/',
    name: 'userCenter',
    redirect: '/home',
    component: () => import('@/views/personalCenter/index.vue'),
    children: [
      // 主页
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/home/index.vue'),
        // meta也是路由的一个属性,这里设置这个属性,是来缓存有这个属性的组件,把不需要缓存的组件过滤掉
        meta: {
          keepAlive: true
        }
      },
      // 问答
      { path: '/answer', name: 'answer', component: () => import('@/views/answer/index.vue') },
      // 视频
      { path: '/video', name: 'video', component: () => import('@/views/video/index.vue') },
      // 我的
      { path: '/mine', name: 'mine', component: () => import('@/views/mine/index.vue') }
    ]
  },
  // 搜索的路由模块
  { path: '/search', name: 'search', component: () => import('@/views/search/index.vue') },
  // 文章列表项的文章内容的路由模块
  { path: '/articlecontent/:articleId', name: 'articlecontent1', component: () => import('@/views/articleContent/index.vue'), props: true },
  // 编辑用户资料的路由模块
  { path: '/userdata', name: 'userdata', component: () => import('@/views/userData/index.vue') }
]

const router = new VueRouter({
  routes
})

export default router
